﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2024/5/30
 * 时间: 17:42
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Runtime.Serialization;

namespace dailyEnglish
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			label1.BackColor = Color.Transparent;
            label1.Parent = pictureBox1;
            
            label2.BackColor = Color.Transparent;
            label2.Parent = pictureBox1;
            
			WebClient webClient = new WebClient();
			webClient.Encoding = System.Text.Encoding.UTF8;
			string html=webClient .DownloadString("https://api.vvhan.com/api/dailyEnglish");
			string[] zh= html.Split(new string[] { "zh\": \"" ,"\"en\":"}, StringSplitOptions.None);
			label2.Text=zh[1].Replace("\",","");
			string[] en= html.Split(new string[] { "en\": \"" ,"\"pic"}, StringSplitOptions.None);
			label1.Text=en[1].Replace("\",","");
			string[] pic= html.Split(new string[] { "pic\": \""}, StringSplitOptions.None);
			 
			ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
			  Byte[] imgData = webClient.DownloadData(pic[1].Replace("\"","").Replace("}","").Trim());
			  Stream ms = new MemoryStream(imgData);
			  ms.Position = 0;
			  Image img = Image.FromStream(ms);
			 pictureBox1.Image=img;
			
			 
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
	}
}
